package main

import (
	"bufio"
	"os"
	"fmt"
)

func main() {
	//count := make(map[string]int)

	//input := bufio.NewScanner(os.Stdin)

	//for input.Scan() {
	//	if(input.Text() == "n"){
	//		break;
	//	}
	//	count [input.Text()]++
	//}

	//fmt.Println("结果是:")
	//for k,v :=range count {
	//	fmt.Printf("%s\t%d\n",k,v)
	//}
	counts := make(map[string]int)

	files :=os.Args[1:]
	if len(files) ==0 {
		countLines(os.Stdin,counts)
	} else {
		for _,arg :=range files {
			f,err := os.Open(arg)
			if err != nil {
				fmt.Fprintf(os.Stderr,"dup2:,%v\n",err)
				continue;
			}
			countLines(f,counts)
			f.Close()
		}
	}

	for k,v := range counts {
		fmt.Println(k,"--",v)
	}

}

func countLines(f *os.File,counts map[string]int) {
	input := bufio.NewScanner(f)
	for input.Scan() {
		if input.Text() == "n" {
			break;
		}
		counts[input.Text()]++
	}
}
